<template>
  <div>
    <h4 style="text-align: center; color: #0070C0">编制合同</h4>
    <el-descriptions class="margin-top" :column="3" :size="size" border>
      <el-descriptions-item label="物资编码">
      <el-input v-model="contract.contNum"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="签订日期">
        <el-input type="date" v-model="contract.contDate"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="合同类型">
        <el-input v-model="contract.contType"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="买方">
        <el-input v-model="contract.buyer"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="卖方">
        <el-input v-model="contract.seller"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="采购类型">
        <el-input v-model="contractApply.contractApplyStockEntity.stockEntity.dictEntity.desc"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="币别">
        <el-input v-model="contract.money"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="汇率">
        <el-input v-model="contract.exchange"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="税率">
        <el-input v-model="contract.taxRate"></el-input>
      </el-descriptions-item>
    </el-descriptions>
    <el-descriptions class="margin-top" :column="2" :size="size" border>
      <el-descriptions-item label="付款条件">
        <el-input v-model="contract.payCond"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="验收时间">
        <el-input type="date" v-model="contract.verifyDate"></el-input>
      </el-descriptions-item>
    </el-descriptions>
    <el-descriptions class="margin-top" :column="3" :size="size" border>
      <el-descriptions-item label="合同金额(元)">
        <el-input type="number" readonly v-model="contract.contPrice"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="运输费用负担">
        <el-input v-model="contract.transport"></el-input>
      </el-descriptions-item>
      <el-descriptions-item label="付款方式">
        <el-input v-model="contract.payWay"></el-input>
      </el-descriptions-item>
    </el-descriptions>
    <el-input v-model="overdue"></el-input>
    <el-table-column
      prop="quoCompany"
      label="供应商"
      width="180">
    </el-table-column>
    <el-table-column
      prop="quoteDetail.amount"
      label="数量"
      width="180">
    </el-table-column>
    <el-table-column
      prop="quoteDetail.unitPrice"
      label="单价（元/含税）">
    </el-table-column>
    <el-table-column
      prop="quoteDetail.mixPrice"
      label="运杂费（元）">
    </el-table-column>
    <el-table-column
      prop="quoteDetail.otherPrice"
      label="其它费用（元）">
    </el-table-column>
    <el-table-column
      prop="quoteDetail.sumPrice"
      label="总计（元）">
    </el-table-column>
    <el-table-column
      prop="planStartDate"
      label="计划开始交货期">
    </el-table-column>
    <el-table-column
      prop="endDate"
      label="结束交货期">
    </el-table-column>
    <el-descriptions class="margin-top" :column="1" :size="size" border>
      <el-descriptions-item label="备注">
        <el-input v-model="contract.remark"></el-input>
      </el-descriptions-item>
    </el-descriptions>
    <el-input value="合同模板说明"></el-input>


    <div class="bottom">
      <el-button type="primary" @click="dataFormSubmit">录入</el-button>
      <el-button @click="goBack">返回</el-button>
    </div>
  </div>
</template>

<script>
import quote from "@/views/quote/index.vue";
import {cloneObj} from "@/utils";
import contract from "@/views/contract/index.vue";

export default {
  data() {
    return {
      size: '',
      msg:"hello",
      overdue:`逾期违约：供方逾期交货的，应按逾期交货金额每日千分之${contract.outPerm}向需方支付违约金，逾期超过${contract.outDay}天，需方有权解除合同。`,
      contract:{
        "contNum": "",// 合同编号
        "buyer": "", //买方
        "seller": "", //卖方
        "supplierNum": "", //供应商编号
        "contDate": "", //签订时间
        "contType": "", //合同类型
        "stockType": "", //采购类型
        "money": "", //币别
        "taxRate": "", //税率
        "verifyStand": "",
        "mode": "", //运输方式
        "payCond": "", //付款条件
        "verifyDate": "", //验收时间
        "contPrice": "10000", //总金额
        "transport": "", //运输费用负担
        "payWay": "", //付款方式
        "outPerm": "", //预期千分比
        "outDay": "",  //预期天数
        "remark": "", //备注
        "exchange": "" //汇率
      },
      contractApply:{
          contractApplyStockEntity:{
            stockEntity:{
              dictEntity:{
                desc:""
              }
            }

          }
        }

    }
  },
  mounted() {
    let id = this.$route.query.id;
    this.id = id
    this.getData()
    // console.log(this.contractDetail)
    // this.gettypeData()
  },
    methods: {
      getData() {
        this.$http({
          url: this.$http.adornUrl(`purchase/contract/stock/${this.id}`),
          method: 'get',

        }).then((data) => {
          console.log(data)
          if (data && data.code === 200) {
            this.contractApply = data.contract
          }
        })
      },
      goBack(){
        this.$router.go(-1);
      },
      dataFormSubmit(){
        console.log(this.contract)
        this.$http({
          url: this.$http.adornUrl(`/purchase/contract/save`),
          method: 'post',
          data: this.$http.adornData(
            this.contract
          )
        }).then((data) => {
          if (data && data.code === 200) {
            console.log(this.details)
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
            })
            this.getData()
            this.contract= ""
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
::v-deep .el-descriptions-item__cell.el-descriptions-item__label.is-bordered-label {
  width: 150px
}
.bottom{
  //margin-top: 20px;
  margin: 20px;
  text-align: right;
}
</style>
